package com.willy.ratingbar;

import ohos.agp.components.AttrSet;
import ohos.app.Context;
import ohos.eventhandler.EventHandler;
import ohos.eventhandler.EventRunner;

import java.util.UUID;

/**
 * Created by willy on 2017/5/5.
 */

public class AnimationRatingBar extends BaseRatingBar {

    protected EventHandler mHandler;
    protected Runnable mRunnable;

    protected AnimationRatingBar(Context context, AttrSet attrs) {
        super(context, attrs);
        init();
    }

    protected AnimationRatingBar(Context context, AttrSet attrs, String defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }

    private void init() {
        EventRunner runner = EventRunner.create(true);
        mHandler = new EventHandler(runner);
    }

    protected void postRunnable(Runnable runnable, long animationDelay) {
        if (mHandler == null) {
            EventRunner runner = EventRunner.create(true);
            mHandler = new EventHandler(runner);
        }
        mHandler.postTask(runnable, animationDelay, EventHandler.Priority.IMMEDIATE);
    }
}